package com.miao.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miao.admin.dao.AdminRefundDao;
import com.miao.common.entity.pojo.Refund;
import com.miao.admin.service.AdminRefundService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 退货记录表(Refund)表服务实现类
 *
 * @author makejava
 * @since 2021-02-22 17:48:32
 */
@Service
public class AdminRefundServiceImpl extends ServiceImpl<AdminRefundDao, Refund> implements AdminRefundService {


    @Override
    public List<Refund> getAllRefund(int sId) {


        QueryWrapper<Refund> wrapper = new QueryWrapper<Refund>()
                .eq("store_id", sId)
                .select("ref_id","ref_appliy_time","cus_id","money","op_time","ref_state");
        return this.list(wrapper);
    }

    @Override
    public Refund getRefundInfo(String rId) {
        return this.getById(rId);
    }

    @Override
    public boolean chgRefundState(String rId,int state) {

        Refund refund = new Refund();
        refund.setRefId(rId);
        refund.setRefState(state);
        refund.setOpTime(new Date());
        return this.updateById(refund);
    }
}